package com.kstech.mp3604.ui

/**
 * author: blankii
 * created on: 2025/3/18 13:12
 * description:
 */
//object PowerStatus {
//}


enum class PowerStatus {
    POWER_ONE, POWER_TWO, POWER_THREE, POWER_FULL
}

var lastStatus: PowerStatus = PowerStatus.POWER_ONE

interface PowerStatusListener {
    fun setPowerStatus(powerValue: Int) {
        var currentStatus: PowerStatus = PowerStatus.POWER_ONE
        when (powerValue) {
            in 0..25 -> {
                currentStatus = PowerStatus.POWER_ONE
            }

            in 25..50 -> {
                currentStatus = PowerStatus.POWER_TWO
            }

            in 50..75 -> {
                currentStatus = PowerStatus.POWER_THREE
            }

            in 75..100 -> {
                currentStatus = PowerStatus.POWER_FULL
            }/*
            不满足的异常数据不显示
            或者输出到错位日志中
             */
//            else -> {
//                DbManager.db.errorInfoDao().addErrorInfo(
//                    ErrorInfo(
//                        ERROR_TYPE_1, "rx接收收据异常,正常范围[0-100],异常接收值:$powerValue", "1", "2"
//                    )
//                )
//                return
//            }

        }
        if (lastStatus != currentStatus) {
            changePowerStatus(currentStatus)
            lastStatus = currentStatus
        }
    }

    fun changePowerStatus(status: PowerStatus)
}